package com.cbgolf.oa.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.cbgolf.oa.R;
import com.cbgolf.oa.activity.order.OrderActivity;
import com.cbgolf.oa.util.ClassUtil;
import com.cbgolf.oa.util.DataUtil;
import com.cbgolf.oa.util.ViewUtils;
import com.cbgolf.oa.widget.autolayout.utils.AutoUtil;

/**
 * @author lq
 * @date 2017/7/23
 */

public class DialogActivity extends AppCompatActivity {

  @BindView(R.id.ll_dlg_pub_layout)
  View layout;
  @BindView(R.id.tv_dlg_pub_title)
  TextView titleTv;
  @BindView(R.id.tv_dlg_pub_content)
  TextView contentTv;
  @BindView(R.id.tv_dlg_pub_cancel)
  TextView cancelTv;
  @BindView(R.id.tv_dlg_pub_submit)
  TextView subMitTv;

  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dialog_public);
    AutoUtil.auto(this);
    init();
  }

  private void init() {
    findViews();
    setViews();
    setListener();
  }

  private void findViews() {
    ButterKnife.bind(this);
  }

  private void setListener() {
    ViewUtils.setClick(cancelTv, v -> finish());
    ViewUtils.setClick(subMitTv, v -> {
      ClassUtil.startActivity(this, OrderActivity.class);
      finish();
    });
  }

  private void setViews() {
    LinearLayout.LayoutParams ll = (LinearLayout.LayoutParams) layout.getLayoutParams();
    ll.height = LayoutParams.WRAP_CONTENT;
    ll.width = getWindowManager().getDefaultDisplay().getWidth() * 4 / 5;
    layout.setLayoutParams(ll);
    Intent intent = getIntent();
    String title = DataUtil.getStringExtra(intent, "title");
    String content = DataUtil.getStringExtra(intent, "msg");
    ViewUtils.setText(subMitTv, "查看");
    ViewUtils.setText(titleTv, title);
    ViewUtils.setText(contentTv, content);

  }
}


